//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: AutoNumberItem.cs
//
//  Description: An item containing an auto number property.
// 
//--------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;

namespace Chili.Opf3.Query
{
	/// <summary>
	/// Represents an autonumber item.
	/// </summary>
	/// <remarks>
	/// This class represents an autonumber item. It is created during each creation of 
	/// an insert command where auto numbers are involved.
	/// </remarks>
	public sealed class AutoNumberItem
	{
		private FieldAttribute _field;
		private object _value;

		/// <summary>
		/// Creates a new instance of the <see cref="AutoNumberItem">AutoNumberItem Class</see>.
		/// </summary>
		/// <param name="field">The field that is marked as auto number in the persistent object.</param>
		/// <param name="value">The value for the auto number field. If the value for the autonumber is created
		/// during creation of the insert statement this value is set.</param>
		public AutoNumberItem(FieldAttribute field, object value)
		{
			_field = field;
			_value = value;
		}

		/// <summary>
		/// Creates a new instance of the <see cref="AutoNumberItem">AutoNumberItem Class</see>.
		/// </summary>
		/// <param name="field">The field that is marked as auto number in the persistent object.</param>
		public AutoNumberItem(FieldAttribute field)
		{
			_field = field;
		}

		/// <summary>
		/// Returns the field marked as auto number in the persistent object.
		/// </summary>
		public FieldAttribute FieldAttribute
		{
			get { return _field; }
		}

		/// <summary>
		/// Returns the value for the auto number field. This property is only set if the value for the 
		/// auto number property is created during creation of the insert statement. Otherwise it is null.
		/// </summary>
		public object Value
		{
			get { return _value; }
		}
	}
}
